//
//  MainViewController.m
//  TrunkIndustryManageSystem
//
//  Created by 李璐西 on 15-3-26.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "MainViewController.h"
#import "BiNetEngine.h"


@interface MainViewController ()<UIScrollViewDelegate, BiNetEngineDelegate>

@end

@implementation MainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    
    // 模拟请求
    [[BiNetEngine shareInstance] requestCarSaleCheckList:self index:0];
    
    _naviBarView = [[BiNaviBarView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
    [self.view addSubview:_naviBarView];
    [_naviBarView setHidden:NO];
    [_naviBarView setTitle:@"客户信息审批"];
    
//    [self setBackgroundColor:UIColorFromRGB(0x1ca0ff)];
    CGRect frame = [self.view bounds];
    UIScrollView *background = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, 320, frame.size.height)];
    [self.view addSubview:background];
    background.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:242.0/255.0 blue:247.0/255.0 alpha:100];
//    滚动
    background.contentSize = CGSizeMake(320, frame.size.height+100);
    background.delegate = self;
#pragma mark view1
////   background1*********************************************************
//
//
////    view2*********************************************************
//    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 20, 320, 78)];
//    view2.backgroundColor = [UIColor whiteColor];
//    [background addSubview:view2];
//    
////    left
//    NSString *string3 = @"从业年限:";
//    UILabel *lablev2_1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 39, 44, 44)];
//    CGSize titleSize1 = [string3 sizeWithFont:lablev2_1.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
//    lablev2_1.text = @"从业年限:";
//    lablev2_1.font = [UIFont systemFontOfSize:14];
//    lablev2_1.lineBreakMode = NSLineBreakByClipping;
//    lablev2_1.backgroundColor = [UIColor redColor];
//    [view2 addSubview:lablev2_1];
//    lablev2_1.frame = CGRectMake(10, titleSize1.height, titleSize1.width, 44);
//
//    
//    NSString *string4 = @"10年";
//    UILabel *lablev2_2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 39, 320, 44)];
//    CGSize titleSize2 = [string4 sizeWithFont:lablev2_1.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
//    lablev2_2.text = @"10年";
//    lablev2_2.font = [UIFont systemFontOfSize:14];
//    lablev2_2.lineBreakMode = NSLineBreakByClipping;
//    lablev2_2.backgroundColor = [UIColor blueColor];
//    [view2 addSubview:lablev2_2];
//    lablev2_2.frame = CGRectMake(10+titleSize1.width, titleSize1.height, titleSize2.width, 44);
////    right
//    NSString *string5 = @"民族:";
//    UILabel *lablev2_3 = [[UILabel alloc] initWithFrame:CGRectMake(10+160, 39, 44, 44)];
//    CGSize titleSize3 = [string5 sizeWithFont:lablev2_3.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
//    lablev2_3.text = @"民族:";
//    lablev2_3.font = [UIFont systemFontOfSize:14];
//    lablev2_3.lineBreakMode = NSLineBreakByClipping;
//    lablev2_3.backgroundColor = [UIColor redColor];
//    [view2 addSubview:lablev2_3];
//    lablev2_3.frame = CGRectMake(10+160, titleSize1.height, titleSize3.width, 44);
//    
//    NSString *string6 = @"汉族";
//    UILabel *lablev2_4 = [[UILabel alloc] initWithFrame:CGRectMake(10+160, 39, 320, 44)];
//    CGSize titleSize4 = [string6 sizeWithFont:lablev2_4.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
//    lablev2_4.text = @"汉族";
//    lablev2_4.font = [UIFont systemFontOfSize:14];
//    lablev2_4.lineBreakMode = NSLineBreakByClipping;
//    lablev2_4.backgroundColor = [UIColor blueColor];
//    [view2 addSubview:lablev2_4];
//    lablev2_4.frame = CGRectMake(10+160+titleSize3.width, titleSize1.height, titleSize4.width, 44);
#define ViewW 80
#define ViewH 78
#define ViewL 10
#define ViewR 20
    
    for (int i = 1; i < 7; i++)
    {
        NSLog(@"1");
        UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 30 + i * 40, 320, 40)];
        view2.backgroundColor = [UIColor whiteColor];
        [background addSubview:view2];
//    left
        NSString *string3 = @"从业年限:";
        UILabel *lablev2_1 = [[UILabel alloc] initWithFrame:CGRectMake(10,39, 44, 44)];
        CGSize titleSize1 = [string3 sizeWithFont:lablev2_1.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
//        CGSize titleSize1 =[string3 sizeWithFont:lablev2_1.font constraninedToSize:CGSizeMake(FLT_MAX,FLT_MAX)];
        lablev2_1.text = @"从业年限:";
        lablev2_1.font = [UIFont systemFontOfSize:14];
        lablev2_1.lineBreakMode = NSLineBreakByClipping;
        lablev2_1.backgroundColor = [UIColor redColor];
        [view2 addSubview:lablev2_1];
        lablev2_1.frame = CGRectMake(10,titleSize1.height - 20, titleSize1.width, 44);
        
        NSString *string4 = @"10年";
        UILabel *lablev2_2 = [[UILabel alloc] initWithFrame:CGRectMake(10,39, 320, 44)];
        CGSize titleSize2 = [string4 sizeWithFont:lablev2_1.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
        lablev2_2.text = @"10年";
        lablev2_2.font = [UIFont systemFontOfSize:14];
        lablev2_2.lineBreakMode = NSLineBreakByClipping;
        lablev2_2.backgroundColor = [UIColor blueColor];
        [view2 addSubview:lablev2_2];
        lablev2_2.frame = CGRectMake(10+titleSize1.width,titleSize1.height- 20, titleSize2.width, 44);
//    right
        NSString *string5 = @"民族:";
        UILabel *lablev2_3 = [[UILabel alloc] initWithFrame:CGRectMake(10+160, 39, 44, 44)];
        CGSize titleSize3 = [string5 sizeWithFont:lablev2_3.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
        lablev2_3.text = @"民族:";
        lablev2_3.font = [UIFont systemFontOfSize:14];
        lablev2_3.lineBreakMode = NSLineBreakByClipping;
//        lablev2_3.backgroundColor = [UIColor redColor];
        [view2 addSubview:lablev2_3];
        lablev2_3.frame = CGRectMake(10+160, titleSize1.height- 20, titleSize3.width, 44);
        
        NSString *string6 = @"汉族";
        UILabel *lablev2_4 = [[UILabel alloc] initWithFrame:CGRectMake(10+160, 39, 320, 44)];
        CGSize titleSize4 = [string6 sizeWithFont:lablev2_4.font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
        lablev2_4.text = @"汉族";
        lablev2_4.font = [UIFont systemFontOfSize:14];
        lablev2_4.lineBreakMode = NSLineBreakByClipping;
//        lablev2_4.backgroundColor = [UIColor blueColor];
        [view2 addSubview:lablev2_4];
        lablev2_4.frame = CGRectMake(10+160+titleSize3.width, titleSize1.height- 20, titleSize4.width, 44);
        
        
    }
    

    
// ****************************************************
    if (isIOS7)
    {
        [_naviBarView setFrame:CGRectMake(0, 0, _naviBarView.frame.size.width, 64)];
    }
    else
    {
        [_naviBarView setFrame:CGRectMake(0, -20, _naviBarView.frame.size.width, 64)];
    }
    [_naviBarView release];
    
    self.view.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:242.0/255.0 blue:247.0/255.0 alpha:100];
}

- (void)onGetCarSaleCheckList:(id)array
{
    if ([array isKindOfClass:[NSArray class]])
    {
        // 处理网络数据
    }
}

#pragma mark -
#pragma mark BiNetEngineDelegate
- (void)onNetEngineResponse:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    NSLog(@"onNetEngineResponse");
    
    switch (tag)
    {
        case NET_GET_CAR_SALE_CHECK_LIST:
        {
            [self onGetCarSaleCheckList:entity];
        }
            break;
            
        default:
            break;
    }
}
- (void)onNetEngineResponseFail:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    NSLog(@"onNetEngineResponseFail");
}

#pragma mark -------------------
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    // any offset changes
    NSLog(@"%f",scrollView.contentOffset.y);//这里我们输出 scrollView的纵向 偏移量
}
// called on start of dragging (may require some time and or distance to move)
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDragging");
}
// called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSLog(@"scrollViewDidEndDragging willDecelerate");
}
// called on finger up as we are moving
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDecelerating");
}
// called when scroll view grinds to a halt
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSLog(@"scrollViewDidEndDecelerating");
}


- (void)onTextViewButtonClicked:(UIButton*)button
{

}

@end
